package com.xuecheng.media.controller;

import com.xuecheng.api.media.TMediaApi;
import com.xuecheng.api.media.TMediaAuditApi;
import com.xuecheng.api.media.model.dto.MediaDTO;
import com.xuecheng.api.media.model.qo.QueryMediaModel;
import com.xuecheng.common.domain.page.PageRequestParams;
import com.xuecheng.common.domain.page.PageVO;
import com.xuecheng.common.util.SecurityUtil;
import com.xuecheng.media.service.MediaAuditService;
import com.xuecheng.media.service.MediaService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 媒资内容控制器
 *
 * @author lily
 * @date 2021/12/15
 */
@RestController
@Slf4j
public class TMediaAuditController implements TMediaAuditApi {

    // 运营平台标识--可以查询所哟教学机构的数据
    public static final Long OPERATION_FLAG = -99887799L;

    @Autowired
    private MediaService mediaService;

    @Autowired
    private MediaAuditService mediaAuditService;

    /**
     * 查询媒资信息功能实现
     *
     * @param  pageParams 分页数据
     * @param  model      查询数据
     * @return com.xuecheng.api.media.model.dto.MediaDTO
     * @author Lily
     * @date 2021/12/15 16:07
     * @paramType [java.lang.String, java.lang.String]
     * @description
     *
     * 参数会自动封装到对象里面的参数
     */
    @PostMapping("m/media/list")
    @Override
    public PageVO queryMediaByNameOrType(PageRequestParams pageParams, QueryMediaModel model) {
        // Long companyId = SecurityUtil.getCompanyId();
        PageVO pageVO = mediaService.queryMediaList(pageParams, model, OPERATION_FLAG);
        return pageVO;
    }


    /**
     * 运营平台媒资审核
     *
     * @param dto 媒资dto
     * @author Lily
     * @date 2021/12/15 21:06
     * @paramType [com.xuecheng.api.media.model.dto.MediaDTO]
     * @description
     */
    @PutMapping("m/media/audit")
    @Override
    public void mediaAudit(@RequestBody MediaDTO dto) {
        mediaAuditService.mediaAudit(dto);
    }

}
